<template>
  <div>
    <Card title="系统设置" style="width: 800px">
      <Form ref="formValidate" :model="tempData" :label-width="10">
        <FormItem label-position="left" :label-width="160" label="公司名称（打印标题）" prop="configstr1">
         <Input v-model="tempData.configstr1" />
        </FormItem>
        <!-- <FormItem label="" prop="config1">
          <Checkbox size="large" v-model="tempData.config1" :true-value="1" :false-value="0">销售单根据客户自动获取商品上次成交价
          </Checkbox>
        </FormItem>
        <FormItem label="" prop="config2">
          <Checkbox size="large" v-model="tempData.config2" :true-value="1" :false-value="0">采购单自动获取商品上次成交价</Checkbox>
        </FormItem> -->

        <FormItem label="" prop="config4">
          <Checkbox size="large" v-model="tempData.config4" :true-value="1" :false-value="0">销售单、销售退货单金额保留到整数</Checkbox>
        </FormItem>
        <FormItem label="" prop="config5">
          <Checkbox size="large" v-model="tempData.config5" :true-value="1" :false-value="0">采购单、采购退货单金额保留到整数</Checkbox>
        </FormItem>
      </Form>
      <Button type="primary" :loading="loading" @click="SaveSystemConfig">确定</Button>
    </Card>
  </div>
</template>

<script>
import { Message } from 'iview'
import { GetSystemConfig, SaveSystemConfig } from '@/api/data'
export default {
  name: 'systemconfig',
  data () {
    return {
      loading: false,
      tempData: {}
    }
  },
  methods: {
    GetSystemConfig () {
      let vm = this
      GetSystemConfig().then((res) => {
        const data = res.data
        if (data.StatusCode == 200) {
          vm.tempData = data.Data
        } else {
          Message.error({ title: '提示', content: data.Errors })
        }
      })
    },
    SaveSystemConfig () {
      this.loading = true
      SaveSystemConfig(this.tempData).then((res) => {
        this.loading = false
        const data = res.data
        if (data.StatusCode == 200) {
          Message.success('保存成功')
          this.GetSystemConfig()
        } else {
          Message.error({ title: '提示', content: data.Errors })
        }
      })
    }
  },
  mounted () {
    this.GetSystemConfig()
  }
}
</script>

<style>
</style>
